package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Description：交友数据访问层
 * @Author: liulei
 * @Date: 2019年11月01日
 * @Version: V1.0
 **/
public interface FriendDao extends JpaRepository<Friend, String> {

    //根据userid和friendid联合查询
    public Friend findByUseridAndFriendid(String userid, String friendid);

    //更新为互相喜欢
    @Modifying
    @Query(value = "UPDATE tb_friend SET islike=? WHERE userid=? AND friendid=? ", nativeQuery = true)
    public void updateIsLike(String islike, String userid, String friendid);

    //删除好友
    @Modifying
    @Query(value = "delete from tb_friend where userid=? and friendid=? ", nativeQuery = true)
    public void deleteFriend(String userid, String friendid);
}
